Skip to content

Enable versioned docs #1106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 7, 2019
Merged

Conversation

wgao19
Copy link
Contributor

@wgao19 wgao19 commented Dec 8, 2018

What does this PR do?

New doc piece regarding #1001:
Enable versioned docs

Summary of the Changes

  • Add a "versioned docs" page to doc site
  • Add 5.1.1 docs
  • Start 6.0.0 docs

How to work with versioned docs

Docusaurus assumes that master is the docs for next. Once next is released, run yarn version within website/. This copies the diff between current master docs with latest doc site's version to the doc site's created new version.

Notes

  • I've created the 6.0 docs since 6.0 is already released. So for this particular version, we'll need to edit the docs under website/versioned_docs/version-6.0.0/api/api.md, etc. In the future, we should edit docs on master, and simply run yarn version with new version number after release.

  • Docusaurus's versioned docs feature does not assume versioned code. We don't need to keep the code branches of older versions.

@netlify
Copy link

netlify bot commented Dec 8, 2018

Deploy preview for react-redux-docs ready!

Built with commit 8efcb26

https://deploy-preview-1106--react-redux-docs.netlify.com

@markerikson
Copy link
Contributor

Sweet! I'll try to take a look at this over the weekend.

@timdorr
Copy link
Member

timdorr commented Dec 10, 2018

Docusaurus's versioned docs feature does not assume versioned code. We don't need to keep the code branches of older versions.

Can it? We have a 5.x branch that we'll keep around for a bit while folks migrate to 6.0. If we can isolate doc versions by branches, that would actually be ideal.

@markerikson
Copy link
Contributor

markerikson commented Dec 10, 2018

Oh hey, you did cut a 5.x branch. I wasn't sure that we had one.

Per your question: no, I don't think that's how Docusaurus handles things. There's one published site, built from the current Markdown docs files. Older versions of the docs are, I believe, pre-generated HTML files that have been committed (?). But all that has to be on the same branch together, so that it can be copied to the docs build output folder.

@timdorr
Copy link
Member

timdorr commented Dec 10, 2018

Is there a chance to run some script pre-build that essentially does git --work-tree=website/versioned_docs/version-5.1.1/ checkout 5.x -- docs/?

@markerikson
Copy link
Contributor

Technically? Probably. But that's really not how DS is meant to work as far as I know, and I don't think it gains us anything useful.

@wgao19
Copy link
Contributor Author

wgao19 commented Dec 10, 2018

I think Docusaurus' idea is that it assumes master branch is always next. And whenever we run docusaurus-version vx.x, it creates a directory for that version, and generates docs for that version based off the difference between that version and the latest version prior to that.

Only files in the docs directory and sidebar files that differ from those of the latest version will get copied each time a new version is specified. If there is no change across versions, Docusaurus will use the file from the latest version with that file.

In our case latest version was 5.1.1. master was 6.0, which was also @next. Once I ran docusaurus-version 6.0.0, it copied the docs from master that was different from 5.1.1. to versioned_docs/version-6.0.0. I changed api.md regarding forwardRef and passing store. Therefore only api.md was copied.

But all that has to be on the same branch together

Yeah I believe so. The generated versioned docs are under the doc site's directory.

Technically? Probably. But that's really not how DS is meant to work as far as I know, and I don't think it gains us anything useful.

I guess nothing would stop us from writing such script by ourselves. We just need to copy over the docs/ and the versioned_sidebars. The header and footer can be a bit off if they're not consistent across versions. And yeah, probably not how Docusaurus is designed to work.

@timdorr
Copy link
Member

timdorr commented Dec 10, 2018

Thanks for the explanation. In that case, since versioned docs do matter for this project (not so much with Redux, though), I think this looks good.

Mark, did you have any further tweaks to make to the base docs before we split out the versions?

@markerikson
Copy link
Contributor

Yeah, gimme another day or two to finish polishing things.

@timdorr
Copy link
Member

timdorr commented Apr 4, 2019

Any chance we can still get to this? With 7.0 imminent, it's going to be more important.

@wgao19
Copy link
Contributor Author

wgao19 commented Apr 5, 2019

I believe so. I'll spend some time this weekend to catch up a bit, update this branch and let's see.

@wgao19
Copy link
Contributor Author

wgao19 commented Apr 7, 2019

Hi @timdorr, @markerikson,

I've updated this branch and have put v5 to previous version, v6 to stable version, and put up a link to v7 as pre-release version. It should now work under Netlify's preview.

Changes

  • Make version docs work: There's a doc number next to the logo, clicking on it will go to the versioned docs page
  • Older versions are now v5.x, v6.x
    • v5.x: docs before v6 released
    • v6.x: docs of current master
  • Put up a link to v7.x in the versioned docs page, this points to version "next" of the docs, which is the current master

Versioned docs structure

.
├──  # ... other files
├── docs                      # pre-release version (v7)
│   ├── README.md
│   ├── api
│   ├── introduction
│   ├── troubleshooting.md
│   └── using-react-redux
└── website
    ├── # ... other files
    ├── siteConfig.js
    ├── versioned_docs        # contains stable + previous versions
    │   ├── version-5.x       # copies docs/ when running docusaurus' version command
    │   └── version-6.x
    ├── versioned_sidebars 
    │   ├── version-5.x-sidebars.json
    │   └── version-6.x-sidebars.json
    ├── versions.json         # list of versioned files
    └── yarn.lock

Working with versioned docs

  • To update docs for pre-release versions (v7), update the docs under root /docs.
  • To update docs for any stable or previous versions, update the docs under /website/versioned_docs/
  • Once pre-release version releases, run Docusaurus command yarn run version v7.x under /website, and remove nextVersion: 'v7.x' from website/siteConfig.js.

@timdorr
Copy link
Member

timdorr commented Apr 7, 2019

Oh, this is so good! Thank you!

@markerikson Any objections? I'd say just merge this in right now.

@markerikson
Copy link
Contributor

Sure, let's do it! @wgao19 , this is great - thanks!

@markerikson markerikson merged commit eae14cc into reduxjs:master Apr 7, 2019
@wgao19 wgao19 deleted the docs/versioned-docs branch April 8, 2019 02:10
albertodev7 pushed a commit to albertodev7/react-redux that referenced this pull request Dec 8, 2022
* Enable versioned doc

* Start adding 6.0 docs

* Rename 5.1.1 to 5.x and make it work

* Cast v6.x versioned docs

* Display v7.x as pre-release version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants